package com.songlanyun.common.kqUtils;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonValue;
import com.songlanyun.common.drive.IntegerEnum;
import com.songlanyun.common.enums.OpusConstant;

import java.util.Objects;

public class QuickPayEnum {

    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum TxnType implements IntegerEnum<String> {

        ODR("ODR", "下单"), // 下单
        RFD("RFD", "退单"), // 退单
        ;


        @EnumValue
        @JsonValue
        private String code;

        private String msg;

        TxnType(String code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(String code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public String getCode() {
            return code;
        }

        @JsonCreator
        public static QuickPayEnum.TxnType getByCode(String code) {
            for (QuickPayEnum.TxnType value : QuickPayEnum.TxnType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum TxnFlag implements IntegerEnum<String> {

        S("S", "成功"),
        F("F", "失败"),
        ;


        @EnumValue
        @JsonValue
        private String code;

        private String msg;

        TxnFlag(String code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(String code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public String getCode() {
            return code;
        }

        @JsonCreator
        public static QuickPayEnum.TxnFlag getByCode(String code) {
            for (QuickPayEnum.TxnFlag value : QuickPayEnum.TxnFlag.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum PayType implements IntegerEnum<String> {

        W2("W2", "微信"), // 微信
        A2("A2", "支付宝"), // 支付宝
        ;


        @EnumValue
        @JsonValue
        private String code;

        private String msg;

        PayType(String code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(String code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public String getCode() {
            return code;
        }

        @JsonCreator
        public static QuickPayEnum.PayType getByCode(String code) {
            for (QuickPayEnum.PayType value : QuickPayEnum.PayType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

}
